<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="120">
            <Row v-show="!switchFlag" class="query-form">
                <Col span="8">
                    <FormItem label="企业名称：" prop="belongOrgId">
                        <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyName' :orgTree="true" :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="年度：" prop="year" >
                        <DatePicker class="query-form-el" type="year" placeholder="请选择年度" v-model="dataToQuery.year1" :clearable="false"
                                    @on-change="()=>{if(dataToQuery.year1 instanceof Date){dataToQuery.year = dataToQuery.year1.getFullYear().toString()}}"></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8">
                    <Button @click="reset1" class="ivu-btn-reset"  >重置</Button>
                    <Button type="primary" class="ivu-btn-query"   icon="md-search"  @click="query">查询</Button>
                </Col>
            </Row>
            <Row class="query-form">
                <Col span="24">
                    <Button size="large" class="ivu-btn-add"  icon="md-add"  @click="addInfo">新增</Button>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight"  no-data-text="没有查询到相关数据!" @on-selection-change = 'getSelectRows'
               border :columns="columns1"  :data="dataTable">
			   <!-- show-summary -->
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24" >
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
            </Col>
        </Row>
        <Modal :title="mode ==='view'? '生态环境标准化自查报告详情':'生态环境标准化自查报告'" :transfer=false :mask-closable="false" v-model="dialogShow" v-if="dataToView && dialogShow" :width=650 :styles="{height:'auto'}"  class-name='limit-height-dialog' >
            <Row>
                <Col span="24">
                    <Form ref="dialogForm" :class="mode === 'view'?'modal-view-detail':'modal-form'" :show-message="false" :model="dataToView" :rules="mode === 'view'?{} :ruleCustom"  :label-position="mode === 'view'?'right':'top'" :label-width="mode === 'view'?120:null">
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label="二级集团：" prop="belongOrgId">
                                    <div v-if="mode === 'view'">{{dataToView.belongOrgName}}</div>
                                    <!--<Input class="query-form-el" v-else v-model="dataToView.belongOrgName" readonly/>-->
                                    <Select v-else class='w' placeholder="集团名称"  v-model='dataToView.belongOrgId' label-in-value @on-change="belongChange">
                                        <Option v-for="item in twoLevel" :value="item.orgId" :key="item.orgId">{{item.orgName}}</Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label="企业名称：" prop="companyId">
                                    <div v-if="mode === 'view'">{{dataToView.companyName}}</div>
                                    <!--<Input v-else type="text" v-model="dataToView.companyName" readonly></Input>-->
                                    <cascader-dom v-else ref='orgCascader' @setOrgInfo='setCompanyId' @setOrgname="setCompanyName" :orgTree="true"
                                                  :currentOrgId = "dataToView.companyId" :rootOrgId="dataToView.belongOrgId"
                                                  :setCurrentName="{label:dataToView.companyName,value:dataToView.companyId}" ></cascader-dom>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11" >
                                <FormItem label="年度：" prop="yearDate" >
                                    <div v-if="mode === 'view'">{{dataToView.year}}</div>
                                    <!--<Input v-else type="text" v-model="dataToView.year" readonly></Input>-->
                                    <DatePicker v-else type="year" placeholder="请输入" v-model="dataToView.yearDate" :clearable="false"></DatePicker>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label="自查负责人员：" prop="checkCharger" >
                                    <div v-if="mode === 'view'">{{dataToView.checkCharger}}</div>
                                    <Input v-else type="text" v-model="dataToView.checkCharger" ></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11" >
                                <FormItem label="自查开始时间：" prop="startTime" >
                                    <div v-if="mode === 'view'">{{this.renderViewDate(dataToView.startTime)}}</div>
                                    <DatePicker v-else v-model="dataToView.startTime"
                                                :options="{disabledDate(date) {return date && dataToView.endTime && date.valueOf() > dataToView.endTime;}}"
                                                type="date" placeholder="请输入" ></DatePicker>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label="自查结束时间：" prop="endTime" >
                                    <div v-if="mode === 'view'">{{this.renderViewDate(dataToView.endTime)}}</div>
                                    <DatePicker v-else v-model="dataToView.endTime"
                                                :options="{disabledDate(date) {return date && dataToView.startTime && date.valueOf() < dataToView.startTime;}}"
                                                type="date" placeholder="请输入" ></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem v-if="mode === 'view'" label="自查报告文件：">
                                    <div v-show="dataToView.fileIdFiles.length>0" v-for="(item,index) in dataToView.fileIdFiles">
                                        <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                                    </div>
                                </FormItem>
                                <FormItem v-else label="自查报告文件：（请将“企业自评”数据导出并填写问题整改完成时间后，并在次上传）">
                                    <div>
                                        <Upload ref="upload"
                                                :before-upload="(file) => { beforeUpload(file, 'fileId') }"
                                                :show-upload-list="true"
                                                :max-size="10240"
                                                multiple
                                                type="drag"
                                                :action="fileUrl">
                                            <div style="padding: 10px">
                                                <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                                <p>点击将文件拖拽到这里上传</p>
                                                <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                            </div>
                                        </Upload>
                                    </div>
                                    <div v-show="dataToView.fileIdFiles.length>0" v-for="(item,index) in dataToView.fileIdFiles" :key='item'>
                                        <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                                        <Button type="text" icon="md-trash" @click="removeFile(item.id, 'fileId')" style="margin-left: 5px;margin-bottom: 3px"/>
                                      <Progress  v-show="uploadListVisible[index]" :percent="uploadListPercent[index]"></Progress>
                                    </div>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23" >
                                <FormItem label="自查情况描述：" prop="checkDescription" >
                                    <div v-if="mode === 'view'">{{dataToView.checkDescription}}</div>
                                    <Input v-else v-model="dataToView.checkDescription" type="textarea" :rows="2" />
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span='11'>
                                <FormItem label="二级集团环保负责人：" prop="approvalUser">
                                    <div v-if="mode === 'view'">{{dataToView.approvalUserName}}</div>
                                    <Select v-else v-model="dataToView.approvalUser" :label-in-value="true" @on-change="charge">
                                        <Option v-for="item in chargeList" :value="item.userId" :key="item.userId">
                                            {{item.userName}}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='填表时间：' prop='registTime'>
                                    <div v-if="mode === 'view'">{{renderViewDate(dataToView.createDate)}}</div>
                                    <DatePicker v-else type="date" placeholder="请选择日期" class="query-form-el" v-model='dataToView.createDate' readonly></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='填表人：' prop='registrant'>
                                    <div v-if="mode === 'view'">{{dataToView.createUserName}}</div>
                                    <Input v-else type='text' v-model='dataToView.createUserName' readonly></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='填报人手机号：' prop='registrantPhone'>
                                    <div v-if="mode === 'view'">{{dataToView.registrantPhone}}</div>
                                    <Input class="query-form-el" v-else type='text' v-model='dataToView.registrantPhone'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                    </Form>
                </Col>
            </Row>
            <div slot="footer">
                <Button v-if="mode != 'view'" type="primary" :loading="pageStatus.sending" class='ivu-btn-save' @click="submit('dialogForm')" >确定</Button>
                <Button v-if="mode != 'view'" type="primary"  class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
                <Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
            </div>
        </Modal>

        <Modal :transfer=false v-model="model2" :width=500 title="审批" @on-cancel="model2=false;map={}">
            <Form ref="map" v-model="map" :label-width="120">
                <Row class="query-form">
                    <Col span="23">
                        <FormItem label='审批结果：'>
                            <Select v-model='map.approval'>
                                <Option value="2">通过</Option>
                                <Option value="3">退回</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="23">
                        <FormItem label='审批意见：' prop="approvalNotes">
                            <Input placeholder="审批意见" type="textarea" :autosize="{minRows:2,maxRows:5}" v-model='map.approvalNotes'></Input>
                        </FormItem>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="subView(map,1)">确定</Button>
                <Button class='ivu-btn-cancel' @click="model2=false;map={}">取消</Button>
            </div>
        </Modal>

        <Modal :transfer=false v-model="model1" :width=700 title="指派现场审核专家" @on-cancel="model1=false;map={}">
            <Form class="query-form" ref="recorderVO" v-model="recorderVO" :rules="ruleCustom1"  :label-width="140">
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label='审核专家：' prop="experts">
                            <!--<Select multiple v-model="recorderVO.expertList" filterable :label-in-value="true" @on-change="expert">-->
                                <!--<Option v-for="item in expertArr" :value="item.userId" :key="item.userId">-->
                                    <!--{{item.userName}}-->
                                <!--</Option>-->
                            <!--</Select>-->
                            <Input type="text" v-model="recorderVO.expertNames" readonly @on-focus="openExpertSelector(0)"/>
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11" >
                        <FormItem label="计划开始时间：" prop="startTime" >
                            <DatePicker v-model="recorderVO.startTime" type="date" placeholder="请输入" ></DatePicker>
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="计划结束时间：" prop="endTime" >
                            <DatePicker v-model="recorderVO.endTime" type="date" placeholder="请输入" ></DatePicker>
                        </FormItem>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="subView(recorderVO,2)">确定</Button>
                <Button class='ivu-btn-cancel' @click="model1=false;recorderVO={}">取消</Button>
            </div>
        </Modal>

        <Modal title="专家选择" :transfer=false footer-hide v-model="expertSelectModal" :width=1000>
            <expertSelect ref="selExpert" :selectUsers=selectUsers @getActivityData="getActivityData" :envType="true"
                          @closeModal1="closeModal1">
            </expertSelect>
        </Modal>
    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    import expertSelect from "../../safe/audit/expertSelect.vue"

    var cascaderDom = () => import('@/components/cascader-dom.vue');
    export default {
        name: "selfReport",
        components:{
            cascaderDom,expertSelect
        },
        data(){
            return{
                ...this.createCommonDataField(),
                fileUrl:Api.interestedPartiesUserFile,
                downloadUrl:Api.downloadMongoFile,
                columns1: [
                    { title: '序号', width: 65, fixed: 'left', align: 'center', render: pageCommonFunction.indexColumnsRender.bind(this)},
                    {key: 'approval', title: '审批状态', align: 'center', minWidth: 90, render: (h, params) => {
                            return h('span', {style: {color: params.row.approval=='1'?'blue':params.row.approval=='3'?'red':params.row.approval=='2'||params.row.approval=='4'?'green':'red'}},
                                params.row.approval=='1'?'待审批':params.row.approval=='3'?'审批退回':params.row.approval=='2'?'审批通过':params.row.approval=='4'?'标准指标已上传':'待提交')
                        }},
                    {title: '年度', minWidth: 80, align: 'center', key:'year',},
                    {title: '所属二级集团', align: 'center', key:'belongOrgName', minWidth: 220,},
                    {title: '企业名称', align: 'center', key:'companyName', minWidth: 220,},
                    {title: '问题数量', minWidth:90, align: 'center', key:'allRectifyNumber',},
                    {title: '已整改数量', minWidth:100, align: 'center', key:'rectifyNumber',},
                    {title: '未整改数量', minWidth:100, align: 'center', key:'noRectifyNumber',},
                    {title: '自查开始时间', minWidth: 120, align: 'center', key:'startTime', render: this.renderCellDate},
                    {title: '自查结束时间', minWidth: 120, align: 'center', key:'endTime', render: this.renderCellDate},
                    {title: '自查负责人', minWidth: 100, align: 'center', key:'checkCharger', tooltip:true,},
                    {title: '填报人', minWidth: 100, align: 'center', key:'createUserName'},
                    {title: '填报时间', minWidth: 120, align: 'center', key:'createDate', render: this.renderCellDate},
                    {title: '二级集团环保负责人', minWidth: 120, align: 'center', key:'approvalUserName',},
                    {title: '审批意见', minWidth: 120, align: 'center', key:'approvalNotes', tooltip:true},
                    {
                        title: '现场审核专家',
                        minWidth: 120,
                        align: 'center',
                        // key:'approvalNotes',
                        tooltip:true,
                        render: (h, params) => {
                            return h('span', params.row.recorderVO.expertNames)
                        }
                    },
                    // this.getActionColumns()
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 250,
                        align: 'center',
                        render: (h, params) => {
                            const enable = this.currentUser.loginId === this.Common.admin || this.currentUser.userId === params.row.createUserId ||this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined || this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined;
                            return h('div', [
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '14px',},
                                    on: {
                                        click: () => {
                                            this.viewData(params);
                                        }
                                    }
                                }, '详情'),
                                h('Divider', { props: { type: 'vertical' } }, ''),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '14px', color: (params.row.approval==0||params.row.approval==3)&&enable?'':'#c5c8ce',pointerEvents:(params.row.approval==0||params.row.approval==3)&&enable?'':'none'},
                                    on: {
                                        click: () => {
                                            if((params.row.approval==0||params.row.approval==3)&&enable) {
                                                this.editData(params);
                                            }
                                        }
                                    }
                                }, '修改'),
                                h('Divider', { props: { type: 'vertical' } }, ''),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '14px', color: (params.row.approval==0||params.row.approval==3)&&enable?'red':'#c5c8ce',pointerEvents:(params.row.approval==0||params.row.approval==3)&&enable?'':'none'},
                                    on: {
                                        click: () => {
                                            if((params.row.approval==0||params.row.approval==3)&&enable) {
                                                this.deleteData(params);
                                            }
                                        }
                                    }
                                }, '删除'),
                                h('Divider', { props: { type: 'vertical' } }, ''),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {
                                        fontSize: '14px',
                                        color: (params.row.allRectifyNumber && params.row.allRectifyNumber=== params.row.rectifyNumber)&&enable?'#c5c8ce':'',
                                        pointerEvents:(params.row.allRectifyNumber && params.row.allRectifyNumber=== params.row.rectifyNumber)&&enable?'none':''},
                                    on: {
                                        click: () => {
                                            this.$router.push({path: '/problemRectifyDetails', query: {id: params.row.recorderVO.id,type:0}});
                                        }
                                    }
                                }, '整改'),
                                h('Divider', { props: { type: 'vertical' } }, ''),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '14px', color: (params.row.approval==0||params.row.approval==3)&&enable?'':'#c5c8ce',pointerEvents:(params.row.approval==0||params.row.approval==3)&&enable?'':'none'},
                                    on: {
                                        click: () => {
                                            if((params.row.approval==0||params.row.approval==3)&&enable) {
                                                params.row.approval=1
                                                this.subView(params.row,1);
                                            }
                                        }
                                    }
                                }, '提交'),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.approval==1&&(params.row.approvalUser==this.currentUser.userId||this.Common.userIdList.includes(this.currentUser.userId)||this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined)?'':'#c5c8ce',
                                        pointerEvents:params.row.approval==1&&(params.row.approvalUser==this.currentUser.userId||this.Common.userIdList.includes(this.currentUser.userId)||this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined)?'':'none'},
                                    on: {
                                        click: () => {
                                            if(params.row.approval==1&&(params.row.approvalUser==this.currentUser.userId||this.Common.userIdList.includes(this.currentUser.userId)||this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined)) {
                                                this.model2=true
                                                this.map={
                                                    approval:'2',
                                                    checkId:params.row.checkId,
                                                    createUserId:params.row.createUserId,
                                                    companyId:params.row.companyId,
                                                    year:params.row.year
                                                }
                                            }
                                        }
                                    }
                                }, '审批'),
                                h('Divider', { props: { type: 'vertical' } }, ''),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '14px', color: params.row.recorderVO.auditState==0&&params.row.approval==2&&(params.row.approvalUser==this.currentUser.userId||this.currentUser.loginId === this.Common.admin ||this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined||this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined)?'':'#c5c8ce'},
                                    on: {
                                        click: () => {
                                            if(params.row.recorderVO.auditState==0&&params.row.approval==2&&(params.row.approvalUser==this.currentUser.userId||this.currentUser.loginId === this.Common.admin ||this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined||this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined)) {
                                                this.model1=true
                                                this.recorderVO= params.row.recorderVO
                                                this.recorderVO.levelType=3
                                                // this.recorderVO.expertList=this.recorderVO.experts?this.recorderVO.experts.split(","):[]
                                            }
                                        }
                                    }
                                }, '指派现场审核专家'),
                            ]);
                        }
                    },
                ],
                ruleCustom : {
                    yearDate: [{ required: true, message: '  ', trigger: 'blur',type:'date' }],
                    companyId: [{ required: true, message: '  ', trigger: 'blur' }],
                    approvalUser: [{ required: true, message: ' ', trigger: 'blur' }],
                    registrantPhone: [{
                        validator: (rule, value, callback) => {
                            if(!(/^1[3456789]\d{9}$/.test(this.dataToView.registrantPhone))){
                                callback(' ');
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'blur'
                    }],
                },
                ruleCustom1: {
                   /* startTime: [{required: true, message: '  ', trigger: 'blur' ,type: 'date'}],
                    endTime: [{required: true, message: '  ', trigger: 'blur' ,type: 'date'}],
                    experts: [{
                        validator: (rule, value, callback) => {
                            if ((value == null || value == '' || value == undefined) && this.recorderVO.experts.length < 1) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],*/
                },
                // api
                queryUrl:Api.querySelfReport,
                deleteUrl:Api.deleteSelfReport,
                updateUrl:Api.updateSelfReport,
                saveUrl:Api.saveSelfReport,
                model2:false,
                map:{},
                chargeList:[],
                expertArr:[],
                model1:false,
                recorderVO:{},
                twoLevel:[],
                selectUsers:[],
                expertSelectModal:false
            }
        },
       /* computed: {
            currentUser() {
                return JSON.parse(sessionStorage('userId').get('userId'))
            },
        },*/
        mounted() {
            this.setTableHeight();
            this.industryNameArr(this.currentUser.twoLevelOrgId)
            // this.$http.get(Api.queryRoleUser + "/" +"9a6bd6f6fd1a49fc866e98d9ed41f622", {params: {}}).then((res) => {
            //     this.expertArr = res.data.data;//审计专家
            // })
            this.$http.get(Api.quqeryTwoOrgInfo).then(res => {
                this.twoLevel=res.data.data
            })
            this.dataToQuery.year1 = new Date()
            this.dataToQuery.year = new Date().getFullYear().toString()
            this.query();
        },
        methods:{
            ...pageCommonFunction,

            openExpertSelector(isLeader) {
                this.$refs.selExpert.isLeader = isLeader
                this.$refs.selExpert.form2 = {
                    members: this.recorderVO.expertNames ? this.recorderVO.expertNames : '',
                    membersId: '',
                    membersUserId: ''
                }
                this.selectUsers = []
                let hasVal = this.recorderVO.expertIds && this.recorderVO.expertIds.length > 1
                let mId = hasVal ? this.recorderVO.expertIds.split(',') : []
                let mName = hasVal ? this.recorderVO.expertNames.split(',') : []
                let mUId = hasVal ? this.recorderVO.experts.split(',') : []
                let i = 0
                mId.forEach(v => {
                    let userInfo = {name: mName[i], expertId: v, userId: mUId[i]}
                    i++
                    this.selectUsers.push(userInfo)
                })

                this.expertSelectModal = true;
            },
            getActivityData(row) {
                console.log('getActivityData(row)', row)
                if (this.$refs.selExpert.isLeader == 0) {
                    this.recorderVO.expertIds = row.membersId.join(',')
                    this.recorderVO.expertNames = row.members.join(',')
                    this.recorderVO.experts = row.membersUserId.join(',')
                }
            },
            closeModal1() {
                this.expertSelectModal = false;
                this.selectUsers = []
            },
            belongChange(value) {
                this.dataToView.belongOrgId = value.value
                this.dataToView.belongOrgName = value.label
                this.industryNameArr(value.value)
                this.$refs.orgCascader.resetCurrentOrg();
            },
            industryNameArr(twoLevelOrgId){
                this.$http.get(Api.queryRoleUser + "/" +"4394c51057e543e6946354a8941a8767", {params: {twoLevel:twoLevelOrgId}}).then((res) => {
                    this.chargeList = res.data.data;
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                });
            },
            deleteData(params) {
                params.row.id = params.row.checkId
                this.deleteDateAjax(params);
            },
            query() {
                this.queryAjax()
            },
            reset1() {
                this.dataToQuery = {
                    year1: new Date(),
                    year : new Date().getFullYear().toString()
                };
                if (this.$refs.queryOrgCascader) {
                    this.$refs.queryOrgCascader.resetCurrentOrg();
                }
                this.pagedata.currentPage=1
                this.query()
            },
            expert(value){
                // this.map.experts = value.value;
                // this.map.approvalUserName = value.label;
            },
            charge(value){
                this.dataToView.approvalUser = value.value;
                this.dataToView.approvalUserName = value.label;
            },
            subView(row,type){
                if (type == 2) {
                    if (row.experts.length < 1) {
                        this.$Message.info('审核专家不能为空')
                    }else {
                        let url = Api.updateEnvSelfCheck
                        // row.experts = row.expertList.join(",")
                        this.$Modal.confirm({
                            title: '提示',
                            content: '<p>是否要提交？</p>',
                            onOk: () => {
                                this.$http.post(url, row).then((res) => {
                                    this.$Message.info('提交成功')
                                    this.query()
                                    this.model1=false
                                }).catch(res =>{
                                    this.$Message.info('提交异常')
                                })
                            },
                            onCancel: () => {
                                this.query()
                                this.model1=false
                            }
                        });
                    }
                }else {
                    let url=this.updateUrl
                    this.$Modal.confirm({
                        title: '提示',
                        content: '<p>是否要提交？</p>',
                        onOk: () => {
                            this.$http.put(url, row).then((res) => {
                                this.$Message.info('提交成功')
                                this.query()
                                this.model2=false
                            })
                        },
                        onCancel: () => {
                            this.query()
                            this.model2=false
                        }
                    });
                }
            },
            submit(name) {
                if(this.dataToView.yearDate) {
                    this.dataToView.year = this.dataToView.yearDate.getFullYear();
                }
                this.submitAjax(name);
            },
            createEmptyDataToAdd() {
                return {
                    fileId:this.get_uuid(),
                    fileIdFiles:[],
                    approval:0,
                    yearDate:new Date()
                }
            },
            async beforeEditDialogOpen(data) {
                this.industryNameArr(data.row.belongOrgId)
                data.row.yearDate = new Date(data.row.year + '-01-01');
            },
            async afterDataToViewInit() {
                await this.getFiles('fileId');
            }
        },
        watch:{
        },

    }
</script>

<style lang='css' scoped>
    .ivu-form-item {
        padding-right: 20px;
    }

    .query-form-el, .ivu-date-picker, .ivu-input-wrapper {
        width: 100%;
    }
</style>
